package com.jingdianjichi.practice.server.rpc;



import com.jingdianjichi.auth.api.UserFeignService;
import com.jingdianjichi.auth.entity.AuthUserDTO;
import com.jingdianjichi.auth.entity.Result;
import com.jingdianjichi.practice.server.rpc.entity.UserInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * ClassName:UserRpc
 * Package:com.jingdianjichi.subject.infra.rpc
 * Description:
 *
 * @Author fst
 * @Create 2025/1/4 17:09
 * @Version 1.0
 */
@Component
public class UserRpc
{
    @Resource
    private UserFeignService userFeignService;

    public UserInfo getUserInfo(String userName)
    {
        AuthUserDTO authUserDTO =new AuthUserDTO();
        authUserDTO.setUserName(userName);
        Result<AuthUserDTO> result =userFeignService.getUserInfo(authUserDTO);

        UserInfo userInfo = new UserInfo();

        if(result.getSuccess())
        {
            userInfo = new UserInfo();
            userInfo.setUserName(result.getData().getUserName());
            userInfo.setNickName(result.getData().getNickName());
            userInfo.setAvatar(result.getData().getAvatar());
            return userInfo;
        }
        return userInfo;
    }
}
